<template>
    用户名:
    <input type="text" v-model="state.loginData.userName" />
    密码:
    <input type="password" v-model="state.loginData.password" />
    <input type="submit" value="登录" @click="loginSubmit" />

    <ul>
        <li v-for="p in state.processes" :key="p.id">
            {{p.id}} {{p.name}} {{p.workingSet}}
        </li>
    </ul>
</template>

<script>
    import axios from 'axios';
    import {reactive,onMounted} from 'vue';

    export default{
        name:'Login',
        setup(){
            const state=reactive({loginData:{},processes:[]});
            const loginSubmit=async()=>{
                const payload = state.loginData;//获取到用户输入的用户名和密码信息,发给服务器端的参数对象
                const resp = await axios.post('http://localhost:5002/Login/Login', payload);
                console.log(resp);
                let data = resp.data;
                if (!data.ok) {
                    alert("登录失败!");
                    return;
                }
                state.processes = data.processInfos;
            };
            return {state,loginSubmit};
        },
    }

</script>